package com.thingsgrid.device.controller;

import com.thingsgrid.device.entity.DefaultConfig;
import com.thingsgrid.device.service.IDefaultConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
//@AllArgsConstructor
@RequestMapping("/defaultConfig")
@Api(value = "配置记录信息接口", tags = "接口")
public class DefaultConfigController {
    @Autowired
    private IDefaultConfigService DefaultConfigService;
    /**
     * 新增
     */
    @PostMapping("/submit")
    @ApiOperation(value = "新增操作", notes = "传入DefaultConfig实体", position = 1)
    public void save(@Valid @RequestBody DefaultConfig DefaultConfig) {
        DefaultConfigService.saveDefaultConfig(DefaultConfig);
    }

    /**
     * 删除
     */
    @PostMapping("/remove")
    @ApiOperation(value = "逻辑删除", notes = "传入ids", position = 2)
    public void remove(@ApiParam(value = "主键集合", required = true) @RequestParam Character ids) {
        DefaultConfigService.removeDefaultConfig(ids);
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation(value = "修改", notes = "传入shadow", position = 3)
    public void update(@Valid @RequestBody DefaultConfig DefaultConfig) {
        DefaultConfigService.updateDefaultConfig(DefaultConfig);
    }

    /**
     * 查找所有
     */
    @GetMapping("/selectAll")
    @ApiOperation(value = "查询所有", notes = "", position = 4)
    public R<List<DefaultConfig>> selectAll() {
        return R.data(DefaultConfigService.findAll());
    }
    /**
     * 根据id查信息
     */
    @GetMapping("/detail")
    @ApiOperation(value = "查询一个", notes = "传递记录id", position = 5)
    public DefaultConfig selectById(@ApiParam(value = "DefaultConfigId", required = true) @RequestParam Character DefaultConfigId) {
        //productService.updateProduct(product);
        return DefaultConfigService.findDefaultConfigById(DefaultConfigId);
    }
    /**
     * 分页查询
     */
//	@GetMapping("/list")
//	@ApiOperation(value = "分页", notes = "传入页数和每页显示的条数", position = 6)
//	public List<Product> pageList(@ApiParam(value = "页数和条数", required = true)
//								  @RequestParam Integer current, Integer size){
//		return productService.findAll(current,size);
//
//	}

    /**
     * 用户列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "列表", notes = "传入account和realName", position = 2)
    public R<List<DefaultConfig>> pageList(@ApiParam(value = "页数和条数", required = true)
                                          @RequestParam Integer current, Integer size){
        return R.data(DefaultConfigService.findAll(current,size));

    }
}


